// 把request引进来，相当于把request中的promise对象引进来，promise里是一个请求方法
import request from "request.js"

// 请求接口
// 首页
export const GetHomeList = () => request("/index/index");

// 搜索数据请求
export const getSearch = () => request("/search/index");
// 清除历史记录接口
export const clearHistory = () => request("/search/clearhistory");
// 实时搜索
export const searchData = (params) => request("/search/helper", {
  data: params,
  header: {
    "content-type": "application/x-www-form-urlencoded"
  },
});
// 搜索框商品搜索
// export const GoodsSearch = (params)=>request("/goods/list",{params});
export const GoodsSearch = (params) => request("/goods/list", {
  data: params,
});
// 分类详情
export const category=(params)=>request("/goods/category",{data:{
  id:params
}});
export const category2=(params)=>request("/goods/list",{data:{
  categoryId:params
}});

// 专题页
// export const GetTopicList = () => request("/topic/list");
export const GetTopicList=(params,params2)=>request("/topic/list",{data:{
  page:params,
  size:params2
}});
// 分类页
export const GetTypeIndex = () => request("/catalog/index");
// 分类右侧
export const GetTypeCurrent = (params) => request("/catalog/current",{data:{id:params}});
// 登录的数据请求
export const LoginFn = (params) => request("/auth/loginByWeb", {
  data: params,
  header: {
    "content-type": "application/x-www-form-urlencoded"
  },
  method: "POST"
});
// 详情
export const GetGoodsDetail = (params) => request("/goods/detail",{data:{id:params}});
// 相关产品
export const GetGoodsRelated = (params) => request("/goods/related",{data:{id:params}});
// 加入购物车
export const GetCartAdd = (params,params2,params3) => request("/cart/add",{data:{goodsId:params,productId:params2,number:params3},method:"post"});
// 获取购物车数据
export const GetCartIndex= () => request("/cart/index");
// 删除商品
export const GetCartDel= (params) => request("/cart/delete",{data:{productIds:params},method:"post"});
// 编辑步进器
export const bu=(params,params2,params3,params4)=>request("/cart/update",{
  data:{
    goodsId:params,
    id:params2,
    number:params3,
    productId:params4 
},
  method:"POST"
}
 );
//  点击切换商品选中状态
export const huan=(params,params2)=>request("/cart/checked",{
  data:{
    isChecked:params,
    productIds:params2
},
  method:"POST"
}
 );




/* // 组件里的内容
GetHomeList()
  .then(res => {
    console.log(res);
  })
  .catch(err => {
    console.log(err);
  }) */